package learn.advance.stringbuilder1;


//import com.sun.org.apache.xpath.internal.operations.String;

class Demo1StringBuilder {
    public static void Test() {
        StringBuilder bu1 = new StringBuilder();
        System.out.println("bu1:" + bu1);

        StringBuilder bu2 = new StringBuilder("abc");
        System.out.println("bu2:" + bu2);
    }
}

class Demo2StringBuilder{
    public static void Test(){
        StringBuilder bu=new StringBuilder();
        StringBuilder bu2=bu.append("abc");

        System.out.println(bu);
        System.out.println(bu2);
        System.out.println(bu==bu2);//true

        StringBuilder bu3=bu.append(1).append(true).append("中");
        System.out.println(bu);
        System.out.println(bu3);

        System.out.println(bu.length());

    }
}

class Demo3StringBuilder{
    public static void Test(){
        String s="hello";
        System.out.println(s);
        StringBuilder bu=new StringBuilder(s);
        bu.append(" world");
        System.out.println(bu);

        String s2=bu.toString();
        System.out.println(s2);
    }
}


public class TestStringuilder {

    public static void main(String[] args) {
        //Demo1StringBuilder.Test();
        //Demo2StringBuilder.Test();

        Demo3StringBuilder.Test();
    }

}
